<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="每笔业务的请求编号,规则调用ID,全局唯一" prop="entryId">
        <el-input
          v-model="queryParams.entryId"
          placeholder="请输入每笔业务的请求编号,规则调用ID,全局唯一"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品编号" prop="productCode">
        <el-input
          v-model="queryParams.productCode"
          placeholder="请输入产品编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="执行模式(0同步/1异步)" prop="runType">
        <el-input
          v-model="queryParams.runType"
          placeholder="请输入执行模式(0同步/1异步)"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="决策流编号" prop="workflowCode">
        <el-input
          v-model="queryParams.workflowCode"
          placeholder="请输入决策流编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业务类型(1授信/2提现)" prop="operType">
        <el-input
          v-model="queryParams.operType"
          placeholder="请输入业务类型(1授信/2提现)"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户号" prop="custNo">
        <el-input
          v-model="queryParams.custNo"
          placeholder="请输入客户号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申请流水号" prop="applySerialNo">
        <el-input
          v-model="queryParams.applySerialNo"
          placeholder="请输入申请流水号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="借据流水号" prop="loanSerialNo">
        <el-input
          v-model="queryParams.loanSerialNo"
          placeholder="请输入借据流水号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否返回结果标记(1是/0否)" prop="recFlag">
        <el-input
          v-model="queryParams.recFlag"
          placeholder="请输入是否返回结果标记(1是/0否)"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in stateOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:RuleIn:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:RuleIn:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:RuleIn:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:RuleIn:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="RuleInList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="PK" align="center" prop="id"/>
      <el-table-column label="每笔业务的请求编号,规则调用ID,全局唯一" align="center" prop="entryId"/>
      <el-table-column label="产品编号" align="center" prop="productCode"/>
      <el-table-column label="执行模式(0同步/1异步)" align="center" prop="runType"/>
      <el-table-column label="决策流编号" align="center" prop="workflowCode"/>
      <el-table-column label="业务类型(1授信/2提现)" align="center" prop="operType"/>
      <el-table-column label="客户号" align="center" prop="custNo"/>
      <el-table-column label="申请流水号" align="center" prop="applySerialNo"/>
      <el-table-column label="借据流水号" align="center" prop="loanSerialNo"/>
      <el-table-column label="客户姓名" align="center" prop="userName"/>
      <el-table-column label="申请人年龄" align="center" prop="applyAge"/>
      <el-table-column label="手机号码" align="center" prop="mobile"/>
      <el-table-column label="客户邮箱" align="center" prop="email"/>
      <el-table-column label="贷款用途(Business/House rent/Hospital/pharmacy/Education/Agric/Auto/Personal/Salary advance/Other)" align="center"
                       prop="loanUsed"/>
      <el-table-column label="客户所属洲" align="center" prop="continent"/>
      <el-table-column label="银行卡号" align="center" prop="cardNo"/>
      <el-table-column label="BVN号" align="center" prop="bvnNumber"/>
      <el-table-column label="BVN手机号" align="center" prop="bvnMobile"/>
      <el-table-column label="BVN注册时间" align="center" prop="bvnRegisterTime"/>
      <el-table-column label="设备信息-GPS国家" align="center" prop="deviceCountry"/>
      <el-table-column label="设备信息-GPS城市" align="center" prop="deviceCity"/>
      <el-table-column label="设备信息-APP个数" align="center" prop="deviceAppNum"/>
      <el-table-column label="设备信息-IMEI" align="center" prop="deviceimei"/>
      <el-table-column label="设备信息-设备ID" align="center" prop="deviceId"/>
      <el-table-column label="设备信息-是否Root(1是/0否)" align="center" prop="deviceRoot"/>
      <el-table-column label="月收入" align="center" prop="salary"/>
      <el-table-column label="工作职称" align="center" prop="jobtitle"/>
      <el-table-column label="行业" align="center" prop="industry"/>
      <el-table-column label="婚姻状态" align="center" prop="marriage"/>
      <el-table-column label="职业" align="center" prop="occupation"/>
      <el-table-column label="手机品牌" align="center" prop="pbrand"/>
      <el-table-column label="手机型号" align="center" prop="ptype"/>
      <el-table-column label="手机开机时间" align="center" prop="opentime"/>
      <el-table-column label="手机充电次数" align="center" prop="inchargetime"/>
      <el-table-column label="手机当前电量" align="center" prop="battery"/>
      <el-table-column label="手机陀螺仪参数" align="center" prop="tuoluoyi"/>
      <el-table-column label="手机最大内存" align="center" prop="maxstorage"/>
      <el-table-column label="手机已用内存" align="center" prop="usedstorage"/>
      <el-table-column label="当前运营商" align="center" prop="operator"/>
      <el-table-column label="是否有sim卡" align="center" prop="sim"/>
      <el-table-column label="经度" align="center" prop="longitude"/>
      <el-table-column label="纬度" align="center" prop="latitude"/>
      <el-table-column label="地址" align="center" prop="address"/>
      <el-table-column label="wifi名称" align="center" prop="wifiname"/>
      <el-table-column label="联系人姓名" align="center" prop="contactname"/>
      <el-table-column label="关系" align="center" prop="relation"/>
      <el-table-column label="BVN全名" align="center" prop="bvnFullName"/>
      <el-table-column label="BVN得分" align="center" prop="score"/>
      <el-table-column label="BVN环境" align="center" prop="env"/>
      <el-table-column label="BVN最近更新时间" align="center" prop="lastUpdated"/>
      <el-table-column label="BVN生日" align="center" prop="bvnDob"/>
      <el-table-column label="BVN核查结果" align="center" prop="verified"/>
      <el-table-column label="BVN性别" align="center" prop="bvnGender"/>
      <el-table-column label="BVN注册邮箱" align="center" prop="bvnEmail"/>
      <el-table-column label="BVN地址" align="center" prop="bvnAddress"/>
      <el-table-column label="申请人是否逾期(1是/0否)" align="center" prop="applyOverdueFlag"/>
      <el-table-column label="邀请人当前是否逾期(1是/0否)" align="center" prop="inviterOverdueFlag"/>
      <el-table-column label="设备关联的所有用户当前是否逾期(1是/0否)" align="center" prop="deviceAllUserOverdueFlag"/>
      <el-table-column label="注册手机号码关联用户是否逾期(1是/0否)" align="center" prop="correlationUserOverdueFlag"/>
      <el-table-column label="是否返回结果标记(1是/0否)" align="center" prop="recFlag"/>
      <el-table-column label="学历" align="center" prop="education"/>
      <el-table-column label="联系人手机号" align="center" prop="contactmobile"/>
      <el-table-column label="历史授信拒绝次数" align="center" prop="cntCreditReject"/>
      <el-table-column label="最近30天内授信失败次数" align="center" prop="cntCreditFail"/>
      <el-table-column label="BVN手机号关联BVN号码个数" align="center" prop="cntBvn"/>
      <el-table-column label="邮箱关联客户数" align="center" prop="cstMcntMail"/>
      <el-table-column label="最近60天授信申请次数" align="center" prop="cntCredit60Days"/>
      <el-table-column label="最近60天提现申请次数" align="center" prop="cntApply60Days"/>
      <el-table-column label="历史提现拒绝次数" align="center" prop="cntWithdrawReject"/>
      <el-table-column label="客户关联的IMEI个数" align="center" prop="cntImei"/>
      <el-table-column label="设备关联用户数" align="center" prop="cntDevice"/>
      <el-table-column label="通讯录联系人数" align="center" prop="cntContactsNum"/>
      <el-table-column label="状态" align="center" prop="state" :formatter="stateFormat"/>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:RuleIn:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:RuleIn:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改规则调用记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="每笔业务的请求编号,规则调用ID,全局唯一" prop="entryId">
          <el-input v-model="form.entryId" placeholder="请输入每笔业务的请求编号,规则调用ID,全局唯一"/>
        </el-form-item>
        <el-form-item label="产品编号" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入产品编号"/>
        </el-form-item>
        <el-form-item label="执行模式(0同步/1异步)" prop="runType">
          <el-input v-model="form.runType" placeholder="请输入执行模式(0同步/1异步)"/>
        </el-form-item>
        <el-form-item label="决策流编号" prop="workflowCode">
          <el-input v-model="form.workflowCode" placeholder="请输入决策流编号"/>
        </el-form-item>
        <el-form-item label="业务类型(1授信/2提现)" prop="operType">
          <el-input v-model="form.operType" placeholder="请输入业务类型(1授信/2提现)"/>
        </el-form-item>
        <el-form-item label="客户号" prop="custNo">
          <el-input v-model="form.custNo" placeholder="请输入客户号"/>
        </el-form-item>
        <el-form-item label="申请流水号" prop="applySerialNo">
          <el-input v-model="form.applySerialNo" placeholder="请输入申请流水号"/>
        </el-form-item>
        <el-form-item label="借据流水号" prop="loanSerialNo">
          <el-input v-model="form.loanSerialNo" placeholder="请输入借据流水号"/>
        </el-form-item>
        <el-form-item label="客户姓名" prop="userName">
          <el-input v-model="form.userName" placeholder="请输入客户姓名"/>
        </el-form-item>
        <el-form-item label="申请人年龄" prop="applyAge">
          <el-input v-model="form.applyAge" placeholder="请输入申请人年龄"/>
        </el-form-item>
        <el-form-item label="手机号码" prop="mobile">
          <el-input v-model="form.mobile" placeholder="请输入手机号码"/>
        </el-form-item>
        <el-form-item label="客户邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入客户邮箱"/>
        </el-form-item>
        <el-form-item label="贷款用途(Business/House rent/Hospital/pharmacy/Education/Agric/Auto/Personal/Salary advance/Other)" prop="loanUsed">
          <el-input v-model="form.loanUsed"
                    placeholder="请输入贷款用途(Business/House rent/Hospital/pharmacy/Education/Agric/Auto/Personal/Salary advance/Other)"/>
        </el-form-item>
        <el-form-item label="客户所属洲" prop="continent">
          <el-input v-model="form.continent" placeholder="请输入客户所属洲"/>
        </el-form-item>
        <el-form-item label="银行卡号" prop="cardNo">
          <el-input v-model="form.cardNo" placeholder="请输入银行卡号"/>
        </el-form-item>
        <el-form-item label="BVN号" prop="bvnNumber">
          <el-input v-model="form.bvnNumber" placeholder="请输入BVN号"/>
        </el-form-item>
        <el-form-item label="BVN手机号" prop="bvnMobile">
          <el-input v-model="form.bvnMobile" placeholder="请输入BVN手机号"/>
        </el-form-item>
        <el-form-item label="BVN注册时间" prop="bvnRegisterTime">
          <el-input v-model="form.bvnRegisterTime" placeholder="请输入BVN注册时间"/>
        </el-form-item>
        <el-form-item label="设备信息-GPS国家" prop="deviceCountry">
          <el-input v-model="form.deviceCountry" placeholder="请输入设备信息-GPS国家"/>
        </el-form-item>
        <el-form-item label="设备信息-GPS城市" prop="deviceCity">
          <el-input v-model="form.deviceCity" placeholder="请输入设备信息-GPS城市"/>
        </el-form-item>
        <el-form-item label="设备信息-APP个数" prop="deviceAppNum">
          <el-input v-model="form.deviceAppNum" placeholder="请输入设备信息-APP个数"/>
        </el-form-item>
        <el-form-item label="设备信息-IMEI" prop="deviceimei">
          <el-input v-model="form.deviceimei" placeholder="请输入设备信息-IMEI"/>
        </el-form-item>
        <el-form-item label="设备信息-设备ID" prop="deviceId">
          <el-input v-model="form.deviceId" placeholder="请输入设备信息-设备ID"/>
        </el-form-item>
        <el-form-item label="设备信息-是否Root(1是/0否)" prop="deviceRoot">
          <el-input v-model="form.deviceRoot" placeholder="请输入设备信息-是否Root(1是/0否)"/>
        </el-form-item>
        <el-form-item label="月收入" prop="salary">
          <el-input v-model="form.salary" placeholder="请输入月收入"/>
        </el-form-item>
        <el-form-item label="工作职称" prop="jobtitle">
          <el-input v-model="form.jobtitle" placeholder="请输入工作职称"/>
        </el-form-item>
        <el-form-item label="行业" prop="industry">
          <el-input v-model="form.industry" placeholder="请输入行业"/>
        </el-form-item>
        <el-form-item label="婚姻状态" prop="marriage">
          <el-input v-model="form.marriage" placeholder="请输入婚姻状态"/>
        </el-form-item>
        <el-form-item label="职业" prop="occupation">
          <el-input v-model="form.occupation" placeholder="请输入职业"/>
        </el-form-item>
        <el-form-item label="手机品牌" prop="pbrand">
          <el-input v-model="form.pbrand" placeholder="请输入手机品牌"/>
        </el-form-item>
        <el-form-item label="手机型号" prop="ptype">
          <el-input v-model="form.ptype" placeholder="请输入手机型号"/>
        </el-form-item>
        <el-form-item label="手机开机时间" prop="opentime">
          <el-input v-model="form.opentime" placeholder="请输入手机开机时间"/>
        </el-form-item>
        <el-form-item label="手机充电次数" prop="inchargetime">
          <el-input v-model="form.inchargetime" placeholder="请输入手机充电次数"/>
        </el-form-item>
        <el-form-item label="手机当前电量" prop="battery">
          <el-input v-model="form.battery" placeholder="请输入手机当前电量"/>
        </el-form-item>
        <el-form-item label="手机陀螺仪参数" prop="tuoluoyi">
          <el-input v-model="form.tuoluoyi" placeholder="请输入手机陀螺仪参数"/>
        </el-form-item>
        <el-form-item label="手机最大内存" prop="maxstorage">
          <el-input v-model="form.maxstorage" placeholder="请输入手机最大内存"/>
        </el-form-item>
        <el-form-item label="手机已用内存" prop="usedstorage">
          <el-input v-model="form.usedstorage" placeholder="请输入手机已用内存"/>
        </el-form-item>
        <el-form-item label="当前运营商" prop="operator">
          <el-input v-model="form.operator" placeholder="请输入当前运营商"/>
        </el-form-item>
        <el-form-item label="是否有sim卡" prop="sim">
          <el-input v-model="form.sim" placeholder="请输入是否有sim卡"/>
        </el-form-item>
        <el-form-item label="经度" prop="longitude">
          <el-input v-model="form.longitude" placeholder="请输入经度"/>
        </el-form-item>
        <el-form-item label="纬度" prop="latitude">
          <el-input v-model="form.latitude" placeholder="请输入纬度"/>
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入地址"/>
        </el-form-item>
        <el-form-item label="wifi名称" prop="wifiname">
          <el-input v-model="form.wifiname" placeholder="请输入wifi名称"/>
        </el-form-item>
        <el-form-item label="联系人姓名" prop="contactname">
          <el-input v-model="form.contactname" placeholder="请输入联系人姓名"/>
        </el-form-item>
        <el-form-item label="关系" prop="relation">
          <el-input v-model="form.relation" placeholder="请输入关系"/>
        </el-form-item>
        <el-form-item label="BVN全名" prop="bvnFullName">
          <el-input v-model="form.bvnFullName" placeholder="请输入BVN全名"/>
        </el-form-item>
        <el-form-item label="BVN得分" prop="score">
          <el-input v-model="form.score" placeholder="请输入BVN得分"/>
        </el-form-item>
        <el-form-item label="BVN环境" prop="env">
          <el-input v-model="form.env" placeholder="请输入BVN环境"/>
        </el-form-item>
        <el-form-item label="BVN最近更新时间" prop="lastUpdated">
          <el-input v-model="form.lastUpdated" placeholder="请输入BVN最近更新时间"/>
        </el-form-item>
        <el-form-item label="BVN生日" prop="bvnDob">
          <el-input v-model="form.bvnDob" placeholder="请输入BVN生日"/>
        </el-form-item>
        <el-form-item label="BVN核查结果" prop="verified">
          <el-input v-model="form.verified" placeholder="请输入BVN核查结果"/>
        </el-form-item>
        <el-form-item label="BVN性别" prop="bvnGender">
          <el-input v-model="form.bvnGender" placeholder="请输入BVN性别"/>
        </el-form-item>
        <el-form-item label="BVN注册邮箱" prop="bvnEmail">
          <el-input v-model="form.bvnEmail" placeholder="请输入BVN注册邮箱"/>
        </el-form-item>
        <el-form-item label="BVN地址" prop="bvnAddress">
          <el-input v-model="form.bvnAddress" placeholder="请输入BVN地址"/>
        </el-form-item>
        <el-form-item label="申请人是否逾期(1是/0否)" prop="applyOverdueFlag">
          <el-input v-model="form.applyOverdueFlag" placeholder="请输入申请人是否逾期(1是/0否)"/>
        </el-form-item>
        <el-form-item label="邀请人当前是否逾期(1是/0否)" prop="inviterOverdueFlag">
          <el-input v-model="form.inviterOverdueFlag" placeholder="请输入邀请人当前是否逾期(1是/0否)"/>
        </el-form-item>
        <el-form-item label="设备关联的所有用户当前是否逾期(1是/0否)" prop="deviceAllUserOverdueFlag">
          <el-input v-model="form.deviceAllUserOverdueFlag" placeholder="请输入设备关联的所有用户当前是否逾期(1是/0否)"/>
        </el-form-item>
        <el-form-item label="注册手机号码关联用户是否逾期(1是/0否)" prop="correlationUserOverdueFlag">
          <el-input v-model="form.correlationUserOverdueFlag" placeholder="请输入注册手机号码关联用户是否逾期(1是/0否)"/>
        </el-form-item>
        <el-form-item label="是否返回结果标记(1是/0否)" prop="recFlag">
          <el-input v-model="form.recFlag" placeholder="请输入是否返回结果标记(1是/0否)"/>
        </el-form-item>
        <el-form-item label="学历" prop="education">
          <el-input v-model="form.education" placeholder="请输入学历"/>
        </el-form-item>
        <el-form-item label="联系人手机号" prop="contactmobile">
          <el-input v-model="form.contactmobile" placeholder="请输入联系人手机号"/>
        </el-form-item>
        <el-form-item label="历史授信拒绝次数" prop="cntCreditReject">
          <el-input v-model="form.cntCreditReject" placeholder="请输入历史授信拒绝次数"/>
        </el-form-item>
        <el-form-item label="最近30天内授信失败次数" prop="cntCreditFail">
          <el-input v-model="form.cntCreditFail" placeholder="请输入最近30天内授信失败次数"/>
        </el-form-item>
        <el-form-item label="BVN手机号关联BVN号码个数" prop="cntBvn">
          <el-input v-model="form.cntBvn" placeholder="请输入BVN手机号关联BVN号码个数"/>
        </el-form-item>
        <el-form-item label="邮箱关联客户数" prop="cstMcntMail">
          <el-input v-model="form.cstMcntMail" placeholder="请输入邮箱关联客户数"/>
        </el-form-item>
        <el-form-item label="最近60天授信申请次数" prop="cntCredit60Days">
          <el-input v-model="form.cntCredit60Days" placeholder="请输入最近60天授信申请次数"/>
        </el-form-item>
        <el-form-item label="最近60天提现申请次数" prop="cntApply60Days">
          <el-input v-model="form.cntApply60Days" placeholder="请输入最近60天提现申请次数"/>
        </el-form-item>
        <el-form-item label="历史提现拒绝次数" prop="cntWithdrawReject">
          <el-input v-model="form.cntWithdrawReject" placeholder="请输入历史提现拒绝次数"/>
        </el-form-item>
        <el-form-item label="客户关联的IMEI个数" prop="cntImei">
          <el-input v-model="form.cntImei" placeholder="请输入客户关联的IMEI个数"/>
        </el-form-item>
        <el-form-item label="设备关联用户数" prop="cntDevice">
          <el-input v-model="form.cntDevice" placeholder="请输入设备关联用户数"/>
        </el-form-item>
        <el-form-item label="通讯录联系人数" prop="cntContactsNum">
          <el-input v-model="form.cntContactsNum" placeholder="请输入通讯录联系人数"/>
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-select v-model="form.state" placeholder="请选择状态">
            <el-option
              v-for="dict in stateOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listRuleIn, getRuleIn, delRuleIn, addRuleIn, updateRuleIn, exportRuleIn} from "@/api/business/RuleIn";

export default {
  name: "RuleIn",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 规则调用记录表格数据
      RuleInList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 状态字典
      stateOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        entryId: null,
        productCode: null,
        runType: null,
        workflowCode: null,
        operType: null,
        custNo: null,
        applySerialNo: null,
        loanSerialNo: null,
        recFlag: null,
        state: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        custNo: [
          {required: true, message: "客户号不能为空", trigger: "blur"}
        ],
        state: [
          {required: true, message: "状态不能为空", trigger: "change"}
        ],
        createTime: [
          {required: true, message: "创建时间不能为空", trigger: "blur"}
        ],
        updateTime: [
          {required: true, message: "更新时间不能为空", trigger: "blur"}
        ]
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("state").then(response => {
      this.stateOptions = response.data;
    });
  },
  methods: {
    /** 查询规则调用记录列表 */
    getList() {
      this.loading = true;
      listRuleIn(this.queryParams).then(response => {
        this.RuleInList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 状态字典翻译
    stateFormat(row, column) {
      return this.selectDictLabel(this.stateOptions, row.state);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        entryId: null,
        productCode: null,
        runType: null,
        workflowCode: null,
        operType: null,
        custNo: null,
        applySerialNo: null,
        loanSerialNo: null,
        userName: null,
        applyAge: null,
        mobile: null,
        email: null,
        loanUsed: null,
        continent: null,
        cardNo: null,
        bvnNumber: null,
        bvnMobile: null,
        bvnRegisterTime: null,
        deviceCountry: null,
        deviceCity: null,
        deviceAppNum: null,
        deviceimei: null,
        deviceId: null,
        deviceRoot: null,
        salary: null,
        jobtitle: null,
        industry: null,
        marriage: null,
        occupation: null,
        pbrand: null,
        ptype: null,
        opentime: null,
        inchargetime: null,
        battery: null,
        tuoluoyi: null,
        maxstorage: null,
        usedstorage: null,
        operator: null,
        sim: null,
        longitude: null,
        latitude: null,
        address: null,
        wifiname: null,
        contactname: null,
        relation: null,
        bvnFullName: null,
        score: null,
        env: null,
        lastUpdated: null,
        bvnDob: null,
        verified: null,
        bvnGender: null,
        bvnEmail: null,
        bvnAddress: null,
        applyOverdueFlag: null,
        inviterOverdueFlag: null,
        deviceAllUserOverdueFlag: null,
        correlationUserOverdueFlag: null,
        recFlag: null,
        education: null,
        contactmobile: null,
        cntCreditReject: null,
        cntCreditFail: null,
        cntBvn: null,
        cstMcntMail: null,
        cntCredit60Days: null,
        cntApply60Days: null,
        cntWithdrawReject: null,
        cntImei: null,
        cntDevice: null,
        cntContactsNum: null,
        state: null,
        remark: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加规则调用记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRuleIn(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改规则调用记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRuleIn(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRuleIn(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除规则调用记录编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delRuleIn(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有规则调用记录数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportRuleIn(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    }
  }
};
</script>
